package com.ml.netty.handlerchain;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

public class MyClientInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();

        //加入一个出站的handler 对数据进行一个编码
        pipeline.addLast(new MyLongToByteEncoder());

        //这时一个入站的解码器(入站handler )
        pipeline.addLast(new MyByteToLongDecoder()); // 演示入站和出站的调用链
//        pipeline.addLast(new MyReplayingDecoder()); // 演示ReplayingDecoder的功能

        //加入一个自定义的handler ， 处理业务
        pipeline.addLast(new MyClientHandler());
        System.out.println("init client");
    }
}
